/* REXX _cim.zrx by the reverend (build 124) */ /*- built by rev-builder version 1.1 on 02 Jan 2003 at 11:11:20 -*/ /*- ------------------------------------------------------------------------ -*/ /*- Copyright (C) 2001 Ron Wilson -*/ /*- -*/ /*- This script is free, and can be modified for your personal use, but you -*/ /*- cannot copy or distribute this script or any derivative work based upon -*/ /*- this script without the express permission of the author. Your use of -*/ /*- this script is governed by the terms of the REV-LICENSE. -*/ /*- -*/ /*- This program is provided to you WITHOUT ANY WARRANTY, even the implied -*/ /*- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -*/ /*- REV-LICENSE for more details. -*/ /*- -*/ /*- A copy of the REV-LICENSE is available at: -*/ /*- http://thereverend.coastgames.com/tradewars/rev-license.html -*/ /*- ------------------------------------------------------------------------ -*/ /* description: grabs your cim data and fig data. if you have PMAP2.EXE in */ /* your script or log folder then it will parse the data into */ /* useable reports. */ /* rev. 0 - initial release */ /* rev. 1 - updated error response */ /* rev. 2 - added automatic cimparse */ /* rev. 3 - library update */ /* rev. 4 - command prompt no longer required (run anywhere) */ /* rev. 5 - improved ini handling */ /* rev. 6 - added partial options */ /* rev. 7 - library update */ /* rev. 8 - now uses program variable for destination folder */ /* rev. 9 - updated error handling; now uses DownloadAltPath */ /* rev. 10 - major enhancements; new data tracking; new PMAP parser */ /* rev. 11 - now runs makemap whether you pick PMAP or not */ /* rev. 12 - now uses PMAP2 parser; zoc 4.04 compatible */ /* rev. 13 - if you start at the command prompt, it will ask to refresh figs */ /* rev. 14 - revamped the menu */ call zoctimeout 60 call zocsynctime 500 globals=_setglobals() call on halt name _halt cp=_pcheck("Command [") ol=_isonline(1) call _newline _ansi("bt;fgr") parse value _getgameinfo() with spath ";" iname ";" game parse value _getloginfo() with lpath ";" ldefault parse value zocgetglobaloption("DownloadAltPath") with . '="' destfolder '"' ns=_ini_askint("how many sectors in this game?", 5000, iname, game, "ns") alpha=_ini_askint("##DEFAULT##", 0, iname, game, "alpha") rylos=_ini_askint("##DEFAULT##", 0, iname, game, "rylos") sd=_ini_askint("##DEFAULT##", 0, iname, game, "sd") if ns<1 | ns>20000 then call _error "number out of range" cname=_ini_askstr("enter cim filename (no extension):", "cim", iname, game, "cim") if cname="" then call _error "script cancelled by user." call zoctimeout ns%10 _g.1=ldefault parseparams='"/p:'||destfolder||'"' parseparams=parseparams||' "/g:'||lpath||cname||'" /n:'||ns if alpha\="" & alpha\=0 then parseparams=parseparams||" /al:"||alpha if rylos\="" & rylos\=0 then parseparams=parseparams||" /ry:"||rylos if sd\="" & sd\=0 then parseparams=parseparams||" /sd:"||sd pmap=1 select when _fileexists(spath||"pmap2.exe") then pname=spath||"pmap2.exe" when _fileexists(lpath||"pmap2.exe") then pname=lpath||"pmap2.exe" when _fileexists(spath||"pmap2a.exe") then pname=spath||"pmap2a.exe" when _fileexists(lpath||"pmap2a.exe") then pname=lpath||"pmap2a.exe" otherwise pmap=0 end /*if*/ if pmap then menu="port cim;sector cim;refresh figs;refresh voids;PMAP2;bubble report;secludeds report" else menu="port cim;sector cim;refresh figs;refresh voids" select when ol & pmap & cp then default="1;1;1;1;1;1;0" when ol & pmap then default="1;1;0;0;1;1;0" when ol & cp then default="1;1;1;1;0;0;0" when ol then default="1;1;0;0;0;0;0" when pmap then default="0;0;0;0;1;1;0" otherwise default="0;0;0;0;0;0;0" end /*select*/ plist=_mrequestlist("choose options:",menu,";","c",default) tasks="" if ol & _dword(plist,1,";") then tasks=tasks||" portcim" if ol & _dword(plist,2,";") then tasks=tasks||" sectorcim" tasks=translate(strip(tasks),";"," ") if ol & cp & _dword(plist,3,";") then do count=_getfigs(lpath||cname||"_figs.txt") call zocsend "'fig count : "||count||" sector(s) : "||trunc(count/ns*1000)/10||"%^M" end /*if*/ if ol & cp & _dword(plist,4,";") then do count=_getvoids(lpath||cname||"_voids.txt") call zocsend "'void count : "||count||" sector(s) : "||trunc(count/ns*1000)/10||"%^M" end /*if*/ if _dwords(plist,";")>4 then do if \_dword(plist,5,";") then pmap=0 if \_dword(plist,6,";") then parseparams=parseparams||" /b-" if _dword(plist,7,";") then parseparams=parseparams||" /s+" end /*if*/ else pmap=0 /* log cim */ if tasks\="" then do call zocsend "'cim : refresh in progress^M" call _logcim lpath, cname, tasks, ldefault call zocsend "'cim : refresh complete^M" end /*if*/ /* parse cim */ if pmap then do call _newline _ansi("bt;fwh") call zocwriteln '"'||pname||'" '||parseparams call zocwriteln call zocwrite "parsing data ... " code=zocexec('"'||pname||'" '||parseparams,0) if code=0 then call zocwriteln _ansi("bt;fgr")||"SUCCESS!" else call _error "PMAP2 errorlevel "||code end /*if*/ call _quit "nocopy" exit _halt: call off halt call zoclogging 0, 1 call zoclogname _g.1 call zoclogging 1, 1 call zocsend " qqqzn" call zocwriteln call zocwriteln "^[[1;33m<< script aborted by user. >>^[[0;35m " exit return /*** THE REVEREND'S TW LIBRARY FOR ZOC/REXX ***/ /** _setglobals v.3 **/ _setglobals: procedure expose _verbose _monthdays _monthnames _baseday. (globals) _verbose=0 _monthdays="31;28;31;30;31;30;31;31;30;31;30;31" _monthnames="jan;feb;mar;apr;may;jun;jul;aug;sep;oct;nov;dec" _baseday.2000=730118 _baseday.2001=_baseday.2000+365+1 _baseday.2002=_baseday.2001+365 _baseday.2003=_baseday.2002+365 _baseday.2004=_baseday.2003+365 _baseday.2005=_baseday.2004+365+1 _baseday.2006=_baseday.2005+365 _baseday.2007=_baseday.2006+365 _baseday.2008=_baseday.2007+365 rslt="_g. _s. _p. _d. _v. _f. _m. _q. " rslt=rslt||"_ef. _es. _et. _ep. " rslt=rslt||"_path. _dist. _dtomsl. _dfrmsl. " rslt=rslt||"_bg. _nwi. _od. _sv. _pv. _bust. _vs. _vn. " rslt=rslt||"_olist1. _olist2. _clvlist1. _clvlist2. " rslt=rslt||"_verbose _monthdays _monthnames _baseday. " rslt=rslt||"globals reconnect scriptname lra " if arg(1,"E") then rslt=rslt||arg(1) rslt=_space(rslt) return rslt /** _pcheck v.4 **/ _pcheck: procedure expose (globals) pc1=arg(1) pc2=zocgetscreen(0, zocgetinfo("CURSOR-Y"), zocgetinfo("CURSOR-X")) rslt=0 do i=1 to _dwords(pc1,";") if _instr(_dword(pc1,i,";"),pc2,"cs") then rslt=1 end /*do*/ return rslt /** _isonline v.3 **/ _isonline: procedure expose (globals) if zocgetinfo("ONLINE")="##YES##" then return 1 if arg(1,"E") then t=arg(1) else call _error "missing parameter in _isonline" rslt=0 o="##NO##" call time "R" do while time("E")<=t & o\="##YES##" o=zocgetinfo("ONLINE") if o="##YES##" then rslt=1 end /*do*/ return rslt /** _newline v.2 **/ _newline: procedure expose (globals) if zocgetinfo("CURSOR-X")>0 then call zocwriteln arg(1) else call zocwrite arg(1) return /** _ansi v.3 **/ _ansi: procedure expose (globals) rslt="0" do i=1 to _dwords(arg(1),";") w=_dword(arg(1),i,";") select when w="dl" then rslt=rslt||";"||0 /* dull */ when w="bt" then rslt=rslt||";"||1 /* bright */ when w="ul" then rslt=rslt||";"||4 /* underlined */ when w="blk" then rslt=rslt||";"||5 /* blinking */ when w="fbk" then rslt=rslt||";"||30 /* black foreground */ when w="frd" then rslt=rslt||";"||31 /* red foreground */ when w="fgr" then rslt=rslt||";"||32 /* green foreground */ when w="fye" then rslt=rslt||";"||33 /* yellow foreground */ when w="fbl" then rslt=rslt||";"||34 /* blue foreground */ when w="fmg" then rslt=rslt||";"||35 /* magenta foreground */ when w="fcy" then rslt=rslt||";"||36 /* cyan foreground */ when w="fwh" then rslt=rslt||";"||37 /* white foreground */ when w="bbk" then rslt=rslt||";"||40 /* black background */ when w="brd" then rslt=rslt||";"||41 /* red background */ when w="bgr" then rslt=rslt||";"||42 /* green background */ when w="bye" then rslt=rslt||";"||43 /* yellow background */ when w="bbl" then rslt=rslt||";"||44 /* blue background */ when w="bmg" then rslt=rslt||";"||45 /* magenta background */ when w="bcy" then rslt=rslt||";"||46 /* cyan background */ when w="bwh" then rslt=rslt||";"||47 /* white background */ otherwise nop end /*select*/ end /*do*/ rslt="^[["||rslt||"m" return rslt /** _getgameinfo v.5 **/ _getgameinfo: procedure expose (globals) spath=_getscriptpath() base=spath||"script.ini" if arg(1,"E") then fname=arg(1) else fname=base parse value zocgetglobaloption("WindowTitle") with . '="' game '"' if fname\=base | game="" | game="%ZOCORHOST% %OPTIONS%" then do list=_ini_getheadings(fname) if list="##EOF##" then game="##EOF##" else do templist="" do i=1 to _dwords(list,";") temp=_dword(list,i,";") if left(temp,1)\="*" then do if templist="" then templist=temp else templist=templist||";"||temp end /*if*/ end /*do*/ list=templist game=_drequestlist("select a game:", list, ";", "c") end /*else*/ end /*do*/ call zocwrite _ansi("bt;fgr")||"< using " if length(fname)>17 then call zocwrite "..." call zocwriteln right(fname,min(length(fname),17))||" - ["||game||"] >" rslt=spath||";"||fname||";"||game return rslt /** _getloginfo v.2 **/ _getloginfo: procedure expose (globals) parse value zocgetoption("CaptDefaultName") with . '="' ldefault '"' parse value zocgetglobaloption("CapturePath") with . '="' lpath '"' lpath=dosfname(lpath) if right(lpath,1)\="\" then lpath=lpath||"\" if \dosisdir(lpath) then call _error "invalid path in _getloginfo" rslt=lpath||";"||ldefault return rslt /** _ini_askint v.5 **/ _ini_askint: procedure expose (globals) if \arg(1,"E") then msg="enter an integer" else msg=arg(1) do i=2 to 5 if \arg(i,"E") then call _error "missing parameter in _ini_askint" end /*do*/ default=arg(2) fname=arg(3) section=arg(4) key=arg(5) mode=lower(arg(6)) if _stripint(default)\=default then call _error "invalid parameter in _ini_askint" if section="##EOF##" then rslt="##EOF##" else rslt=_ini_read(fname, section, key) select when rslt="##EOF##" & msg="##DEFAULT##" then rslt=_stripint(default) when rslt="##EOF##" then rslt=_askint(msg||" ("||key||"=)",default,"c") when mode="quiet" then rslt=_stripint(rslt) when mode="" then do call zocwrite _ansi("bt;fgr")||"< using " if length(fname)>17 then call zocwrite "..." call zocwriteln right(fname,min(length(fname),17))||" - "||key||"="||rslt||" >" rslt=_stripint(rslt) end /*when*/ otherwise nop end /*select*/ return rslt /** _error v.7 **/ _error: procedure expose (globals) call off halt if zocgetinfo("CURSOR-X")>0 then call zocwriteln call zocwrite _ansi("bt;frd")||"< script error" if arg(1,"E") then call zocwrite ": "||arg(1) call zocwriteln " >" call zocwriteln _ansi("bt;fye")||"< if this is a serious problem, email me at: the.reverend@coastgames.com > " call zocwriteln "< ZOC VERSION '"||zocgetinfo("VERSION")||"', OS '"||zocgetinfo("OSYS")||"', LOCATION '"||zocgetinfo("CONNECTEDTO")||"' >" if arg(2,"E") then call zocwriteln _ansi("bt;fgr")||"< "||arg(2)||" >" call zocwrite _ansi() call _beep "error.wav" if reconnect=1 & arg(1)="timeout" then do /* call zocdisconnect */ call zocwriteln _ansi("bt;fwh")||"< ATTEMPTING TO RECONNECT >" call zocdostring "^RUN=_connect.zrx sn="||scriptname end /*if*/ exit /** _ini_askstr v.5 **/ _ini_askstr: procedure expose (globals) if \arg(1,"E") then msg="enter a number" else msg=arg(1) do i=2 to 5 if \arg(i,"E") then call _error "missing parameter in _ini_askstr" end /*do*/ default=arg(2) fname=arg(3) section=arg(4) key=arg(5) mode=lower(arg(6)) if section="##EOF##" then rslt="##EOF##" else rslt=_ini_read(fname, section, key) select when rslt="##EOF##" & msg="##DEFAULT##" then rslt=default when rslt="##EOF##" then rslt=_askstr(msg||" ("||key||"=)",default,"c") when mode="quiet" then nop when mode="" then do call zocwrite _ansi("bt;fgr")||"< using " if length(fname)>17 then call zocwrite "..." call zocwrite right(fname,min(length(fname),17))||" - " call zocwrite key||"="||left(translate(rslt,"~","^"),min(length(rslt),25)) if length(rslt)>25 then call zocwrite "..." call zocwriteln " >" end /*when*/ otherwise nop end /*select*/ return rslt /** _fileexists v.3 **/ _fileexists: procedure expose (globals) if \arg(1,"E") then call _error "missing parameter in _fileexists" if stream(arg(1), "C", "QUERY EXISTS")="" then rslt=0; else rslt=1 return rslt /** _mrequestlist v.3 **/ _mrequestlist: procedure expose (globals) do i=1 to 3 if \arg(i,"E") then call _error "missing parameter in _mrequestlist" end /*do*/ msg=arg(1) list=arg(2) if list="" then call _error "empty list in _mrequestlist" delim=arg(3) if arg(4,"E") then mode=arg(4) else mode="" if arg(5,"E") then default=arg(5) else default="" yes="> " no=" " if default="" then do rslt=0 menu=" DONE"||delim||no||_dword(list,1,delim) count=_dwords(list,delim) end /*if*/ else do rslt=_dword(default,1,delim) if rslt then menu=" DONE"||delim||yes||_dword(list,1,delim) else menu=" DONE"||delim||no||_dword(list,1,delim) count=min(_dwords(list,delim),_dwords(default,delim)) end /*else*/ if count>1 then do do i=2 to count if default="" then flag=no else do if _dword(default,i,delim) then flag=yes else flag=no end /*else*/ menu=menu||delim||flag||_dword(list,i,delim) if default="" then rslt=rslt||delim||0 else rslt=rslt||delim||_dword(default,i,delim) end /*do*/ end /*if*/ i=_drequestlisti(msg,menu,delim) do while i>1 menu=" DONE" temp="" do j=1 to _dwords(list,delim) if j=(i-1) then do if _dword(rslt,j,delim) then do menu=menu||delim||no||_dword(list,j,delim) if temp="" then temp=0 else temp=temp||delim||0 end /*if*/ else do menu=menu||delim||yes||_dword(list,j,delim) if temp="" then temp=1 else temp=temp||delim||1 end /*else*/ end /*if*/ else do if temp="" then temp=_dword(rslt,j,delim) else temp=temp||delim||_dword(rslt,j,delim) if _dword(rslt,j,delim) then menu=menu||delim||yes||_dword(list,j,delim) else menu=menu||delim||no||_dword(list,j,delim) end /*else*/ end /*do*/ rslt=temp i=_drequestlisti(msg,menu,delim) end /*do*/ if lower(mode)="c" & i=0 then call _quit "script cancelled by user." dmax=_dwords(default,";") lmax=_dwords(list,";") if dmax>lmax then do do i=dmax+1 to lmax rslt=rslt||delim||_dword(default,i,";") end /*do*/ end /*if*/ return rslt /** _dword v.2 **/ _dword: procedure expose (globals) rslt=translate(word(translate(arg(1),arg(3)||" "," "||arg(3)),arg(2))," "||arg(3),arg(3)||" ") return rslt /** _getfigs v.13 **/ _getfigs: procedure expose (globals) fname=arg(1) mode=arg(2) _f.=0 c=0 if lower(mode)="file" then do if _fileopenr(fname) then do call zocwrite _ansi("bt;fye") mon=0 do while \_fileeof(fname) n=linein(fname) if _stripint(n)\="" then do _f.n=1 c=c+1 mon=_spinner(mon,100) end /*if*/ end /*do*/ call _fileclose(fname) call zocwrite " ("||c||") "||_ansi("dl;fmg") end /*if*/ end /*if*/ else do buflen=1024*1024 call zocreceivebuf buflen call zocsend "g" if zocwait("Deployed Fighter Scan")=640 then call _error "timeout" ans=0 do while ans=0 ans=zocwaitmux("r","Total","deployed") end /*do*/ if ans=640 then call _error "timeout" buff=translate(zocreceivebuf(0)," ",d2c(10)||d2c(0)) if length(buff)=buflen then call _error "buffer overflow" call zocwrite _ansi("bt;fye") s=0 i=0 j=0 i=pos(d2c(13),buff,pos("==",buff)+1)+1 if i>1 then j=pos(d2c(13),buff,i) finish=pos("Total",buff,i) mon=0 do while j>0 & j0 then do call lineout fname, i mon=_spinner(mon,100) end /*if*/ end /*do*/ call _fileclose(fname) call zocwriteln " "||_ansi("dl;fmg") end /*if*/ end /*if*/ end /*else*/ return c /** _getvoids v.7 **/ _getvoids: procedure expose (globals) fname=arg(1) mode=arg(2) _v.=0 c=0 if lower(mode)="file" then do if _fileopenr(fname) then do call zocwrite _ansi("bt;fye") mon=0 do while \_fileeof(fname) n=linein(fname) if _stripint(n)\="" then do _v.n=1 c=c+1 mon=_spinner(mon,10) end /*if*/ end /*do*/ call _fileclose(fname) call zocwrite " ("||c||") "||_ansi("dl;fmg") end /*if*/ end /*if*/ else do buflen=16*1024 call zocreceivebuf buflen if _sendwait("cx","")=640 then call _error "timeout" if zocwait("Computer command")=640 then call _error "timeout" call zocsend "q" if zocwaitmux("Command [", "Citadel command")=640 then call _error "timeout" buff=translate(zocreceivebuf(0)," ",d2c(10)||d2c(0)) if length(buff)=buflen then call _error "buffer overflow" call zocwrite _ansi("bt;fye") s=0 i=0 j=0 i=pos("",buff) i=pos(d2c(13),buff,i)+1 i=pos(d2c(13),buff,i)+1 j=pos(d2c(13),buff,i) mon=0 do while j>0 line=_space(substr(buff,i,j-i),1) if line="" then leave if line="No Sectors are currently being avoided." then leave do k=1 to words(line) s1=_stripint(word(line,k)) if s1\="" then do _v.s1=1 c=c+1 s=max(s,s1) end /*if*/ end /*do*/ i=j+1 j=pos(d2c(13),buff,i) mon=_spinner(mon,10) end /*do*/ call zocwrite " ("||c||") "||_ansi("dl;fmg") if fname\="" then do if _fileexists(fname) then call dosdel fname if _filenew(fname) then do call zocwrite _ansi("bt;fye") mon=0 do i=1 to s if _v.i then do call lineout fname, i mon=_spinner(mon,10) end /*if*/ end /*do*/ call _fileclose(fname) call zocwriteln " "||_ansi("dl;fmg") end /*if*/ end /*if*/ end /*else*/ return c /** _dwords v.2 **/ _dwords: procedure expose (globals) rslt=words(translate(arg(1),arg(2)||" "," "||arg(2))) return rslt /** _logcim v.4 **/ _logcim: procedure expose (globals) path=arg(1) fname=arg(2) tasks=arg(3) default=arg(4) if zocgetinfo("VERSION")>=4.03 then call zoclogging 0, 1 else call zoclogging 0 call zocsend "^^?" if zocwait("Interrogation Modes")=640 then call _error "timeout" if zocwait(":")=640 then call _error "timeout" call zocwriteln call zocrespond "[Pause]", " " call zoctimeout 60 do while tasks\="" parse var tasks task ";" tasks select when task="portcim" then ext=".prt" when task="sectorcim" then ext=".sct" otherwise task="" end /*select*/ if task\="" then do if _fileexists(path||fname||ext) then call dosdel path||fname||ext call zoclogname fname||ext call zoclogging 1, 1 call zoctimeout 3000 select when task="portcim" then call zocsend "r" when task="sectorcim" then call zocsend "i" otherwise nop end /*select*/ if zocwait(":")=640 then call _error "timeout" call zoclogging 0, 1 end /*if*/ end /*do*/ call zoctimeout 60 call zocsend "q" if zocwait("ENDINTERROG")=640 then call _error "timeout" call zocrespond "[Pause]" call zoclogname default if zocgetinfo("VERSION")>=4.03 then call zoclogging 1, 1 else call zoclogging 1 return /** _quit v.7 **/ _quit: procedure expose (globals) lcpy=1 arg1="" do i=1 to 2 /* manage arguments */ select when arg(i,"E") & lower(arg(i))="nocopy" then lcpy=0 when arg(i,"E") & arg1="" then arg1=arg(i) otherwise nop end /*select*/ end /*do*/ line=zocgetscreen(0, zocgetinfo("CURSOR-Y"), zocgetinfo("CURSOR-X")) select /* define message */ when lcpy & arg1="" then msg="^[[1;32m< end script >^[[0m^M^J"||line when \lcpy & arg1="" then msg="^[[1;32m< end script >^[[0m " when lcpy then msg="^[[1;32m^M^J< end script: "||arg1||" >^[[0m^M^J"||line when \lcpy then msg="^[[1;32m^M^J< end script: "||arg1||" >^[[0m " otherwise nop end /*select*/ call zocwrite msg select /* choose a beep */ when lower(arg1)="script cancelled by user." then call _beep "cancel.wav" otherwise call _beep "quit.wav" end /*select*/ exit return 1 /** _space v.1 **/ _space: procedure expose (globals) str=strip(arg(1)) if arg(2,"E") then n=arg(2); else n=1 if arg(3,"E") then pad=arg(3); else pad=" " rslt=word(str,1) do i=2 to words(str) rslt=rslt||copies(pad,n)||word(str,i) end /*do*/ return rslt /** _instr v.3 **/ _instr: procedure expose (globals) fnd=arg(1) str=arg(2) if lower(arg(3))\="cs" then do fnd=lower(fnd) str=lower(str) end /*if*/ if arg(1,"E") & arg(2,"E") & pos(fnd,str)>0 then rslt=1 else rslt=0 return rslt /** _getscriptpath v.1 **/ _getscriptpath: parse value zocgetglobaloption("ScriptPath") with . '="' spath '"' spath=dosfname(spath) if right(spath,1)\="\" then spath=spath||"\" if \dosisdir(spath) then call _error "invalid path in _getscriptpath" return spath /** _ini_getheadings v.5 **/ _ini_getheadings: procedure expose (globals) if arg(1,"E") then fname=arg(1) else call _error "missing parameter in _ini_getheadings" if arg(2,"E") then delim=left(arg(2),1) else delim=";" list="" if _fileopenr(fname) then do do while \_fileeof(fname) line=strip(linein(fname)) if left(line,1)="[" then do if list="" then list=strip(translate(line," ","[]")) else list=list||delim||strip(translate(line," ","[]")) end /*if*/ end /*do*/ call _fileclose fname end /*do*/ if list="" then list="##EOF##" return list /** _drequestlist v.3 **/ _drequestlist: procedure expose (globals) i=zocrequestlist(arg(1),translate(arg(2),"|"||arg(3),arg(3)||"|")) select when i<0 & lower(arg(4))="c" then call _quit "script cancelled by user.", "nocopy" when i<0 then rslt="##CANCEL##" otherwise rslt=_dword(arg(2),i+1,arg(3)) end /*select*/ return rslt /** _stripint v.4 **/ _stripint: procedure expose (globals) mask=_space(translate(arg(1)," ","-0123456789"," "),0) rslt=_space(translate(arg(1)," ",mask," "),0) if left(rslt,1)="-" then rslt="-"||_space(translate(rslt," ","-"),0) else rslt=_space(translate(rslt," ","-"),0) if \datatype(rslt,"W") then rslt="" return rslt /** _ini_read v.1 **/ _ini_read: procedure expose (globals) /* argument check */ do i=1 to 3 if \arg(i,"E") | arg(i,"O") then call _error "missing arguments in _ini_read." end /*do*/ /* name arguments */ fname=arg(1) s=strip(arg(2)) k=strip(arg(3)) if _fileopenr(fname) then do done=0 found=0 insection=0 do while \done & \_fileeof(fname) line=strip(linein(fname)) select when left(line,1)=";" then nop when line="["||s||"]" then insection=1 when insection & left(line,1)="[" then done=1 when insection & left(line,length(k)+1)=k||"=" then do v=strip(substr(line,length(k)+2)) done=1 found=1 end /*when*/ otherwise nop end /*select*/ end /*do*/ call _fileclose fname if \found then v="##EOF##" end /*if*/ else v="##EOF##" return v /** _askint v.2 **/ _askint: procedure expose (globals) do i=1 to 3 select when i=1 & arg(i,"E") then msg=arg(i) when i=1 then msg="enter an integer:" when i=2 & arg(i,"E") then default=arg(i) when i=2 then default="" when i=3 & arg(i,"E") then cflag=min(verify(lower(arg(i)),"c","M"),1) when i=3 then cflag=0 otherwise nop end /*select*/ end /*do*/ rslt=strip(zocask(msg, default)) do while _stripint(rslt)\=rslt | rslt="" default=rslt||" [please enter an integer or ESC to cancel.]" if rslt="##CANCEL##" then leave else rslt=strip(zocask(msg, default)) end /*do*/ if cflag & rslt="##CANCEL##" then call _quit "script cancelled by user.", "nocopy" return rslt /** _beep v.2 **/ _beep: procedure expose (globals) select when arg(1,"O") then call zocwrite d2c(7) when _fileexists(arg(1)) then call zocplaysound arg(1) otherwise call zocwrite d2c(7) end /*select*/ return /** _askstr v.1 **/ _askstr: procedure expose (globals) do i=1 to 3 select when i=1 & arg(i,"E") then msg=arg(i) when i=1 then msg="enter an string:" when i=2 & arg(i,"E") then default=arg(i) when i=2 then default="" when i=3 & arg(i,"E") then cflag=min(verify(lower(arg(i)),"c","M"),1) when i=3 then cflag=0 otherwise nop end /*select*/ end /*do*/ rslt=zocask(msg, default) if cflag & rslt="##CANCEL##" then call _quit "script cancelled by user.", "nocopy" return rslt /** _drequestlisti v.2 **/ _drequestlisti: procedure expose (globals) do i=1 to 3 if \arg(i,"E") then call _error "missing parameter in _drequestlisti" end /*do*/ i=zocrequestlist(arg(1),translate(arg(2),"|"||arg(3),arg(3)||"|")) if i<0 & lower(arg(4))="c" then call _quit "script cancelled by user.", "nocopy" else rslt=i+1 return rslt /** _fileopenr v.4 **/ _fileopenr: procedure expose (globals) if \arg(1,"E") then call _error "missing parameter in _fileopenr" if _fileexists(arg(1)) then do call stream arg(1), "C", "OPEN READ" rslt=_fileready(arg(1)) if \rslt then call _fileclose arg(1) end /*if*/ else rslt=0 return rslt /** _fileeof v.4 **/ _fileeof: procedure expose (globals) rslt=\lines(arg(1)) return rslt /** _spinner v.3 **/ _spinner: procedure expose (globals) if arg(1,"E") then count=arg(1) else call _error "missing parameter in _spinner" if arg(2,"E") then width=arg(2) else width=100 if arg(3,"E") & length(arg(3))=5 then chs=arg(3) else chs="-\|/." /* bs="^H" */ bs=d2c(27)||"[1D" select when count=-1 then call zocwrite bs||substr(chs,5,1) when count<0 then count=-1 when count=0 then call zocwrite left(chs,1) when count=width then call zocwrite bs||substr(chs,2,1) when count=(width*2) then call zocwrite bs||substr(chs,3,1) when count=(width*3) then call zocwrite bs||substr(chs,4,1) when count=(width*4) then do call zocwrite bs||left(chs,1) count=0 end /*when*/ otherwise nop end /*select*/ count=count+1 return count /** _fileclose v.3 **/ _fileclose: procedure expose (globals) if \arg(1,"E") then call _error "missing argument in _fileclose" call stream arg(1), "C", "CLOSE" return /** _filenew v.4 **/ _filenew: procedure expose (globals) if \arg(1,"E") then call _error "missing parameter in _filenew" if arg(2,"E") & lower(arg(2))="delete" then call dosdel arg(1) if _fileexists(arg(1)) then rslt=0 else do call stream arg(1), "C", "OPEN WRITE" rslt=_fileready(arg(1)) if \rslt then call _fileclose arg(1) end /*else*/ return rslt /** _sendwait v.1 **/ _sendwait: procedure expose (globals) if \arg(1,"E") | \arg(2,"E") then call _error "missing parameter in _sendwait" call zocsend arg(1) rslt=zocwait(arg(2)) select when \arg(3,"E") | arg(3)="" then nop when lower(arg(3))="timeout" & rslt=640 then call _error "timeout" when lower(arg(3))="lastline" & rslt=640 then call _error "timeout" when lower(arg(3))="lastline" then rslt=_lastline() otherwise nop end /*select*/ return rslt /** _fileready v.1 **/ _fileready: procedure expose (globals) if \arg(1,"E") then call _error "missing parameter in _fileready" if stream(arg(1), "S")\="NOTREADY" then rslt=1; else rslt=0 return rslt /** _lastline v.3 **/ _lastline: procedure expose (globals) rslt=zoclastline() select when lower(arg(1))="raw" then nop when pos(d2c(7),rslt)>0 then rslt=translate(zocstring("REMOVE", rslt, d2c(7))," ",d2c(0)||d2c(10)) otherwise rslt=translate(rslt," ",d2c(0)||d2c(10)) end /*select*/ return rslt